package com.misyi.designpattern.iterator;

import lombok.Data;

/**
 * 没有使用设计模式
 *
 * @author licong
 * @date 2021-09-10 下午8:59
 */
public class WithoutIteratorPatternDemo {

    public static void main(String[] args) {
        Student student1 = new Student();
        student1.setName("小王");
        Student student2 = new Student();
        student2.setName("小明");
        Student[] students = {student1, student2};
        Classroom classroom = new Classroom(students);

        // 遍历教室里的学生
        Student[] classroomStudents = classroom.getStudents();
        for (int i = 0; i < classroomStudents.length; i++) {
            Student classroomStudent = classroomStudents[i];
            System.out.println(classroomStudent);
        }
    }


    /**
     * 学生类
     */
    @Data
    public static class Student {

        private String name;

    }

    /**
     * 教室类
     */
    @Data
    public static class Classroom {

        private Student[] students;


        public Classroom(Student[] students) {
            this.students = students;
        }
    }

}
